package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelOrderRefundapply;
import com.ktgj.hotel.service.IHotelOrderRefundapplyService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 退款申请Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/refundapply")
public class HotelOrderRefundapplyController extends BaseController
{
    @Autowired
    private IHotelOrderRefundapplyService hotelOrderRefundapplyService;

    /**
     * 查询退款申请列表
     */
//    @PreAuthorize(hasPermi = "hotel:refundapply:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody HotelOrderRefundapply hotelOrderRefundapply)
    {
        startPage();
        List<HotelOrderRefundapply> list = hotelOrderRefundapplyService.selectHotelOrderRefundapplyList(hotelOrderRefundapply);
        return getDataTable(list);
    }

    /**
     * 导出退款申请列表
     */
    @PreAuthorize(hasPermi = "hotel:refundapply:export")
    @Log(title = "退款申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrderRefundapply hotelOrderRefundapply) throws IOException
    {
        List<HotelOrderRefundapply> list = hotelOrderRefundapplyService.selectHotelOrderRefundapplyList(hotelOrderRefundapply);
        ExcelUtil<HotelOrderRefundapply> util = new ExcelUtil<HotelOrderRefundapply>(HotelOrderRefundapply.class);
        util.exportExcel(response, list, "退款申请数据");
    }

    /**
     * 获取退款申请详细信息
     */
    @PreAuthorize(hasPermi = "hotel:refundapply:query")
    @GetMapping(value = "/{refunid}")
    public AjaxResult getInfo(@PathVariable("refunid") Long refunid)
    {
        return AjaxResult.success(hotelOrderRefundapplyService.selectHotelOrderRefundapplyById(refunid));
    }

    /**
     * 新增退款申请
     */
    @PreAuthorize(hasPermi = "hotel:refundapply:add")
    @Log(title = "退款申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrderRefundapply hotelOrderRefundapply)
    {
        return toAjax(hotelOrderRefundapplyService.insertHotelOrderRefundapply(hotelOrderRefundapply));
    }

    /**
     * 修改退款申请
     */
    @PreAuthorize(hasPermi = "hotel:refundapply:edit")
    @Log(title = "退款申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrderRefundapply hotelOrderRefundapply)
    {
        return toAjax(hotelOrderRefundapplyService.updateHotelOrderRefundapply(hotelOrderRefundapply));
    }

    /**
     * 删除退款申请
     */
    @PreAuthorize(hasPermi = "hotel:refundapply:remove")
    @Log(title = "退款申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refunids}")
    public AjaxResult remove(@PathVariable Long[] refunids)
    {
        return toAjax(hotelOrderRefundapplyService.deleteHotelOrderRefundapplyByIds(refunids));
    }
}
